package com.example.springproject.xuwsh.config;


import com.example.xuwsh.redis.XuwshRedisConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * @author xuwsh
 */
//@Configuration
@Component
public class RedisConfig implements InitializingBean{
    @Value("${spring.redis.host}")
    public String host;
    @Value("${spring.redis.port}")
    public Integer port;
    @Value("${spring.redis.password}")
    public String password;
    @Value("${spring.redis.jedis.pool.max-idle}")
    public Integer maxIdle;
    @Value("${spring.redis.jedis.pool.min-idle}")
    public Integer minIdle;
    @Value("${spring.redis.timeout}")
    public Integer timeout;

    @Resource
    public XuwshRedisConfig xuwshRedisConfig;

//    @PostConstruct
//    public void getRedisSource() {
//
//    }

    @Override
    public void afterPropertiesSet() throws Exception {
        xuwshRedisConfig.setRedisHost(host);
        xuwshRedisConfig.setPassword(password);
        xuwshRedisConfig.setPort(port);
        xuwshRedisConfig.setMaxIdle(maxIdle);
        xuwshRedisConfig.setMinIdle(minIdle);
        xuwshRedisConfig.setTimeout(timeout);
        xuwshRedisConfig.getRedisConfig();
    }
}